package com.sxl;

import java.util.Vector;

public class VolatileTest {

	/**
	 * @param args
	 */
	
	private static Vector<Integer> vector = new Vector<Integer>();
	public static void main(String[] args) {
		
		System.out.println(System.getProperty("java.version"));
//		while(true) {
			
			for(int i=0; i < 10000; i++) {
				vector.add(i);
			}
//		}
		
		Thread moveThread = new Thread(new Runnable(){
			@Override
			public void run() {
					for (int i=0;i<vector.size();i++) {
						vector.remove(i);
					}
				
			}
			
		});
		
		Thread printThread = new Thread(new Runnable(){
			@Override
			public void run() {
					for (int i=0;i<vector.size();i++) {
						vector.get(i);
//						System.out.print(vector.get(i)+"\t");
//						if (i%20==0) System.out.println();
					}
				
			}
		});
		
		moveThread.start();
		printThread.start();
		
		while (Thread.activeCount() > 20) ; 
	

	}

}


